using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using 道路运输从业人员无纸化考试系统.Properties;

namespace 道路运输从业人员无纸化考试系统
{
	public class XZZJForm : Form
	{
		public const int AW_HOR_POSITIVE = 1;

		public const int AW_HOR_NEGATIVE = 2;

		public const int AW_VER_POSITIVE = 4;

		public const int AW_VER_NEGATIVE = 8;

		public const int AW_CENTER = 16;

		public const int AW_HIDE = 65536;

		public const int AW_ACTIVATE = 131072;

		public const int AW_SLIDE = 262144;

		public const int AW_BLEND = 524288;

		private IContainer components = null;

		private GroupBox groupBox2;

		private GroupBox groupBox3;

		private CheckBox cbDuo;

		private CheckBox cbDan;

		private CheckBox cbPan;

		private Button btnCanel;

		private Button btnBegin;

		private Label label1;

		private RadioButton rbZJ;

		private RadioButton rbQJ;

		private GroupBox groupBox4;

		private Label label2;

		private TextBox txtEnd;

		private TextBox txtBegin;

		private Label label3;

		private Label lbltm;

		private Label label5;

		private Label lblcount;

		private CheckedListBox clbZhangjie;

		private GroupBox groupBox1;

		public XZZJForm()
		{
			InitializeComponent();
		}

		[DllImport("user32.dll")]
		private static extern bool AnimateWindow(IntPtr whnd, int dwtime, int dwflag);

		private void XZZJForm_Load(object sender, EventArgs e)
		{
			bindZhangjie();
			lblcount.Text = GlobamParms.GetCount().ToString();
			AnimateWindow(base.Handle, 1000, 655360);
		}

		private void bindZhangjie()
		{
			DataTable dt = GlobamParms.GetZhangjie();
			clbZhangjie.DataSource = dt;
			clbZhangjie.DisplayMember = "zhangjie";
			clbZhangjie.ValueMember = "zhangjie";
		}

		private void rbZJ_CheckedChanged(object sender, EventArgs e)
		{
			if (rbZJ.Checked)
			{
				groupBox1.Enabled = true;
				groupBox4.Enabled = false;
			}
			else if (rbQJ.Checked)
			{
				groupBox1.Enabled = false;
				groupBox4.Enabled = true;
			}
		}

		private void btnBegin_Click(object sender, EventArgs e)
		{
			GlobamParms.isWhere = " ";
			GlobamParms.ZJ = "";
			if (rbZJ.Checked)
			{
				GlobamParms.Pmode = "ZJ";
				if (clbZhangjie.CheckedItems.Count < 1)
				{
					MessageBox.Show("请至少选择一个章节", "提示");
					return;
				}
				for (int i = 0; i < clbZhangjie.Items.Count; i++)
				{
					if (clbZhangjie.GetItemChecked(i))
					{
						clbZhangjie.SetSelected(i, value: true);
						GlobamParms.isWhere = GlobamParms.isWhere + " zhangjie = '" + clbZhangjie.SelectedValue.ToString() + "' or ";
						try
						{
							int s = int.Parse(clbZhangjie.SelectedValue.ToString().Substring(1, 2));
							GlobamParms.ZJ = GlobamParms.ZJ + clbZhangjie.SelectedValue.ToString().Substring(0, 2) + " | ";
						}
						catch
						{
							GlobamParms.ZJ = GlobamParms.ZJ + clbZhangjie.SelectedValue.ToString().Substring(0, 1) + " | ";
						}
					}
				}
				GlobamParms.isWhere = GlobamParms.isWhere.Substring(0, GlobamParms.isWhere.LastIndexOf(" or"));
				GlobamParms.isWhere = " (" + GlobamParms.isWhere + ") and ";
				GlobamParms.isWhere += "(";
			}
			else if (rbQJ.Checked)
			{
				GlobamParms.Pmode = "QJ";
				if (txtBegin.Text.Trim() == "" || txtEnd.Text.Trim() == "")
				{
					MessageBox.Show("起止值不能为空", "提示");
					return;
				}
				int beginC = int.Parse(txtBegin.Text.Trim());
				int endC = int.Parse(txtEnd.Text.Trim());
				if (beginC >= endC)
				{
					MessageBox.Show("起值要比止值小", "提示");
					return;
				}
				object isWhere = GlobamParms.isWhere;
				GlobamParms.isWhere = isWhere + "(no >=" + beginC + " and no <= " + endC + ") and (";
			}
			if (!cbPan.Checked && !cbDan.Checked && !cbDuo.Checked)
			{
				MessageBox.Show("请至少选择一种题型", "提示");
				return;
			}
			if (cbPan.Checked)
			{
				GlobamParms.isWhere = GlobamParms.isWhere + " type = '" + cbPan.Text + "' or ";
			}
			if (cbDan.Checked)
			{
				GlobamParms.isWhere = GlobamParms.isWhere + " type = '" + cbDan.Text + "' or ";
			}
			if (cbDuo.Checked)
			{
				GlobamParms.isWhere = GlobamParms.isWhere + " type = '" + cbDuo.Text + "' or ";
			}
			GlobamParms.isWhere = GlobamParms.isWhere.Substring(0, GlobamParms.isWhere.LastIndexOf("or "));
			GlobamParms.isWhere += ")";
			GlobamParms.QJ = "第" + txtBegin.Text.Trim() + "题到第" + txtEnd.Text.Trim() + "题";
			if (Text == "顺序练习-选择出题")
			{
				Close();
				SXLXForm sxlxform = new SXLXForm();
				sxlxform.TopMost = true;
				GlobamParms.sxlxform = sxlxform;
				sxlxform.Show();
				GlobamParms.firstform.WindowState = FormWindowState.Minimized;
			}
			else
			{
				Close();
				SJLXForm sjlxform = new SJLXForm();
				sjlxform.TopMost = true;
				GlobamParms.sjlxform = sjlxform;
				sjlxform.Show();
				GlobamParms.firstform.WindowState = FormWindowState.Minimized;
			}
		}

		private void btnCanel_Click(object sender, EventArgs e)
		{
			Close();
		}

		private void clbZhangjie_ItemCheck(object sender, ItemCheckEventArgs e)
		{
		}

		private void XZZJForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			AnimateWindow(base.Handle, 1000, 589824);
		}

		private void XZZJForm_FormClosed(object sender, FormClosedEventArgs e)
		{
			GlobamParms.firstform.WindowState = FormWindowState.Normal;
			GlobamParms.xzzjform = null;
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			groupBox2 = new System.Windows.Forms.GroupBox();
			cbDuo = new System.Windows.Forms.CheckBox();
			cbDan = new System.Windows.Forms.CheckBox();
			cbPan = new System.Windows.Forms.CheckBox();
			groupBox3 = new System.Windows.Forms.GroupBox();
			btnCanel = new System.Windows.Forms.Button();
			btnBegin = new System.Windows.Forms.Button();
			label1 = new System.Windows.Forms.Label();
			rbZJ = new System.Windows.Forms.RadioButton();
			rbQJ = new System.Windows.Forms.RadioButton();
			groupBox4 = new System.Windows.Forms.GroupBox();
			label5 = new System.Windows.Forms.Label();
			lblcount = new System.Windows.Forms.Label();
			lbltm = new System.Windows.Forms.Label();
			txtEnd = new System.Windows.Forms.TextBox();
			txtBegin = new System.Windows.Forms.TextBox();
			label3 = new System.Windows.Forms.Label();
			label2 = new System.Windows.Forms.Label();
			clbZhangjie = new System.Windows.Forms.CheckedListBox();
			groupBox1 = new System.Windows.Forms.GroupBox();
			groupBox2.SuspendLayout();
			groupBox3.SuspendLayout();
			groupBox4.SuspendLayout();
			groupBox1.SuspendLayout();
			SuspendLayout();
			groupBox2.BackColor = System.Drawing.Color.Transparent;
			groupBox2.Controls.Add(cbDuo);
			groupBox2.Controls.Add(cbDan);
			groupBox2.Controls.Add(cbPan);
			groupBox2.Location = new System.Drawing.Point(1, 455);
			groupBox2.Name = "groupBox2";
			groupBox2.Size = new System.Drawing.Size(591, 59);
			groupBox2.TabIndex = 1;
			groupBox2.TabStop = false;
			groupBox2.Text = "题目类型";
			cbDuo.AutoSize = true;
			cbDuo.Checked = true;
			cbDuo.CheckState = System.Windows.Forms.CheckState.Checked;
			cbDuo.Location = new System.Drawing.Point(396, 26);
			cbDuo.Name = "cbDuo";
			cbDuo.Size = new System.Drawing.Size(60, 16);
			cbDuo.TabIndex = 2;
			cbDuo.Text = "多选题";
			cbDuo.UseVisualStyleBackColor = true;
			cbDan.AutoSize = true;
			cbDan.Checked = true;
			cbDan.CheckState = System.Windows.Forms.CheckState.Checked;
			cbDan.Location = new System.Drawing.Point(269, 26);
			cbDan.Name = "cbDan";
			cbDan.Size = new System.Drawing.Size(60, 16);
			cbDan.TabIndex = 1;
			cbDan.Text = "单选题";
			cbDan.UseVisualStyleBackColor = true;
			cbPan.AutoSize = true;
			cbPan.Checked = true;
			cbPan.CheckState = System.Windows.Forms.CheckState.Checked;
			cbPan.Location = new System.Drawing.Point(140, 26);
			cbPan.Name = "cbPan";
			cbPan.Size = new System.Drawing.Size(60, 16);
			cbPan.TabIndex = 0;
			cbPan.Text = "判断题";
			cbPan.UseVisualStyleBackColor = true;
			groupBox3.BackColor = System.Drawing.Color.Transparent;
			groupBox3.Controls.Add(btnCanel);
			groupBox3.Controls.Add(btnBegin);
			groupBox3.Location = new System.Drawing.Point(1, 517);
			groupBox3.Name = "groupBox3";
			groupBox3.Size = new System.Drawing.Size(591, 49);
			groupBox3.TabIndex = 1;
			groupBox3.TabStop = false;
			groupBox3.Text = "操作";
			btnCanel.Location = new System.Drawing.Point(310, 17);
			btnCanel.Name = "btnCanel";
			btnCanel.Size = new System.Drawing.Size(75, 23);
			btnCanel.TabIndex = 1;
			btnCanel.Text = "取  消";
			btnCanel.UseVisualStyleBackColor = true;
			btnCanel.Click += new System.EventHandler(btnCanel_Click);
			btnBegin.Location = new System.Drawing.Point(198, 17);
			btnBegin.Name = "btnBegin";
			btnBegin.Size = new System.Drawing.Size(75, 23);
			btnBegin.TabIndex = 0;
			btnBegin.Text = "开始练习";
			btnBegin.UseVisualStyleBackColor = true;
			btnBegin.Click += new System.EventHandler(btnBegin_Click);
			label1.AutoSize = true;
			label1.BackColor = System.Drawing.Color.Transparent;
			label1.Location = new System.Drawing.Point(184, 12);
			label1.Name = "label1";
			label1.Size = new System.Drawing.Size(65, 12);
			label1.TabIndex = 2;
			label1.Text = "出题方式：";
			rbZJ.AutoSize = true;
			rbZJ.BackColor = System.Drawing.Color.Transparent;
			rbZJ.Checked = true;
			rbZJ.Location = new System.Drawing.Point(252, 10);
			rbZJ.Name = "rbZJ";
			rbZJ.Size = new System.Drawing.Size(59, 16);
			rbZJ.TabIndex = 3;
			rbZJ.TabStop = true;
			rbZJ.Text = "按章节";
			rbZJ.UseVisualStyleBackColor = false;
			rbZJ.CheckedChanged += new System.EventHandler(rbZJ_CheckedChanged);
			rbQJ.AutoSize = true;
			rbQJ.BackColor = System.Drawing.Color.Transparent;
			rbQJ.Location = new System.Drawing.Point(328, 10);
			rbQJ.Name = "rbQJ";
			rbQJ.Size = new System.Drawing.Size(59, 16);
			rbQJ.TabIndex = 4;
			rbQJ.Text = "按区间";
			rbQJ.UseVisualStyleBackColor = false;
			groupBox4.BackColor = System.Drawing.Color.Transparent;
			groupBox4.Controls.Add(label5);
			groupBox4.Controls.Add(lblcount);
			groupBox4.Controls.Add(lbltm);
			groupBox4.Controls.Add(txtEnd);
			groupBox4.Controls.Add(txtBegin);
			groupBox4.Controls.Add(label3);
			groupBox4.Controls.Add(label2);
			groupBox4.Enabled = false;
			groupBox4.Location = new System.Drawing.Point(1, 390);
			groupBox4.Name = "groupBox4";
			groupBox4.Size = new System.Drawing.Size(591, 59);
			groupBox4.TabIndex = 5;
			groupBox4.TabStop = false;
			groupBox4.Text = "题目编号起止值";
			label5.AutoSize = true;
			label5.Location = new System.Drawing.Point(469, 28);
			label5.Name = "label5";
			label5.Size = new System.Drawing.Size(17, 12);
			label5.TabIndex = 6;
			label5.Text = "题";
			lblcount.AutoSize = true;
			lblcount.Location = new System.Drawing.Point(425, 28);
			lblcount.Name = "lblcount";
			lblcount.Size = new System.Drawing.Size(29, 12);
			lblcount.TabIndex = 6;
			lblcount.Text = "1222";
			lbltm.AutoSize = true;
			lbltm.Location = new System.Drawing.Point(354, 28);
			lbltm.Name = "lbltm";
			lbltm.Size = new System.Drawing.Size(65, 12);
			lbltm.TabIndex = 5;
			lbltm.Text = "总题数有：";
			txtEnd.Location = new System.Drawing.Point(281, 25);
			txtEnd.Name = "txtEnd";
			txtEnd.Size = new System.Drawing.Size(63, 21);
			txtEnd.TabIndex = 4;
			txtBegin.Location = new System.Drawing.Point(151, 25);
			txtBegin.Name = "txtBegin";
			txtBegin.Size = new System.Drawing.Size(63, 21);
			txtBegin.TabIndex = 4;
			label3.AutoSize = true;
			label3.Location = new System.Drawing.Point(237, 28);
			label3.Name = "label3";
			label3.Size = new System.Drawing.Size(41, 12);
			label3.TabIndex = 3;
			label3.Text = "止值：";
			label2.AutoSize = true;
			label2.Location = new System.Drawing.Point(107, 28);
			label2.Name = "label2";
			label2.Size = new System.Drawing.Size(41, 12);
			label2.TabIndex = 3;
			label2.Text = "起值：";
			clbZhangjie.BackColor = System.Drawing.Color.Azure;
			clbZhangjie.CheckOnClick = true;
			clbZhangjie.FormattingEnabled = true;
			clbZhangjie.Location = new System.Drawing.Point(175, 13);
			clbZhangjie.Name = "clbZhangjie";
			clbZhangjie.ScrollAlwaysVisible = true;
			clbZhangjie.Size = new System.Drawing.Size(228, 340);
			clbZhangjie.TabIndex = 0;
			clbZhangjie.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(clbZhangjie_ItemCheck);
			groupBox1.BackColor = System.Drawing.Color.Transparent;
			groupBox1.Controls.Add(clbZhangjie);
			groupBox1.Location = new System.Drawing.Point(1, 31);
			groupBox1.Name = "groupBox1";
			groupBox1.Size = new System.Drawing.Size(591, 358);
			groupBox1.TabIndex = 0;
			groupBox1.TabStop = false;
			groupBox1.Text = "章节";
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			BackColor = System.Drawing.Color.White;
			BackgroundImage = 道路运输从业人员无纸化考试系统.Properties.Resources.窗体背景;
			base.ClientSize = new System.Drawing.Size(594, 572);
			base.Controls.Add(groupBox4);
			base.Controls.Add(rbQJ);
			base.Controls.Add(rbZJ);
			base.Controls.Add(label1);
			base.Controls.Add(groupBox3);
			base.Controls.Add(groupBox2);
			base.Controls.Add(groupBox1);
			base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "XZZJForm";
			base.ShowInTaskbar = false;
			base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			Text = "顺序练习-选择出题";
			base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(XZZJForm_FormClosing);
			base.FormClosed += new System.Windows.Forms.FormClosedEventHandler(XZZJForm_FormClosed);
			base.Load += new System.EventHandler(XZZJForm_Load);
			groupBox2.ResumeLayout(false);
			groupBox2.PerformLayout();
			groupBox3.ResumeLayout(false);
			groupBox4.ResumeLayout(false);
			groupBox4.PerformLayout();
			groupBox1.ResumeLayout(false);
			ResumeLayout(false);
			PerformLayout();
		}
	}
}
